package blueBridge;

// 202320232023l
public class NFactor {

    public static void main(String[] args) {
        long num = 40;
        long sum = 0;
        for (long i = 1; i <= num; i++) {
            long factor = 1;
            for (long j = 1; j <= i; j++) {
                factor = (factor * (j % 1000000000l)) % 1000000000l;
            }
            System.out.println(i + ", " + factor + ", " + sum);
            sum = (sum + factor)%1000000000l;
            
        }
        System.out.println(sum);
    }
}
